package com.taokatao.cardmee.util;


import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.View;

import com.taokatao.cardmee.common.widget.MaterialHeader;
import com.taokatao.cardmee.common.widget.RefreshHeader;

import in.srain.cube.views.ptr.PtrFrameLayout;


public class PtrHeaderHelper {

    public static void initDefault(Context context, PtrFrameLayout layPtrFrame) {
        initNormal(context, layPtrFrame);
    }

    public static void initBlank(Context context, PtrFrameLayout layPtrFrame) {
        View header = new View(context);
        int d5 = (int) (5 * context.getResources().getDisplayMetrics().density + 0.5f);
        header.setPadding(0, d5 * 3, 0, d5 * 2);
        layPtrFrame.setDurationToCloseHeader(1500);
        layPtrFrame.setHeaderView(header);
    }
    public static void initMaterial(Context context, PtrFrameLayout layPtrFrame) {
        MaterialHeader header = new MaterialHeader(context);
        int[] colors = new int[]{0xFFEC4E4E};
        header.setColorSchemeColors(colors);
        header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
        int d5 = (int) (5 * context.getResources().getDisplayMetrics().density + 0.5f);
        header.setPadding(0, d5 * 3, 0, d5 * 2);
        header.setPtrFrameLayout(layPtrFrame);
        layPtrFrame.setDurationToCloseHeader(1500);
        layPtrFrame.setHeaderView(header);
        layPtrFrame.addPtrUIHandler(header);
    }

    private static void initNormal(Context context, PtrFrameLayout layPtrFrame) {
        RefreshHeader header = new RefreshHeader(context);
        layPtrFrame.setDurationToCloseHeader(1500);
        layPtrFrame.setHeaderView(header);
        layPtrFrame.addPtrUIHandler(header);
    }
}
